import React from 'react';
import { Input, Button } from 'antd';
import { inject, observer } from 'mobx-react';

@inject('addGoodsMobx')
@observer
class GroupInput extends React.Component {
  render() {
    const { delGroup, index } = this.props;
    let o = {};
    if (this.props.item) {
      o = this.props.item;
    }
    const { formChangePro } = this.props.addGoodsMobx;
    return (
      <>
        <div className="input" style={{ padding: '5px 0' }}>
          <Input
            type="number"
            min={0}
            defaultValue={o.gpNogb}
            onChange={e => formChangePro(index, 1, 'gpNogb', e.target.value)}
          />
          <Input
            type="number"
            min={0}
            defaultValue={o.gpPrice}
            onChange={e => formChangePro(index, 1, 'gpPrice', e.target.value)}
          />
          <Button type="link" onClick={() => delGroup(index)}>
            删除
          </Button>
        </div>
      </>
    );
  }
}
export default GroupInput;
